package com.example.teamtribe.main.seek;

import android.support.v7.widget.SearchView;
import android.view.View;

import com.example.teamtribe.R;
import com.example.teamtribe.base.BaseFragment;
import com.example.teamtribe.event.Refresh;

import org.greenrobot.eventbus.EventBus;

public class SeekFragment extends BaseFragment implements SearchView.OnQueryTextListener, SeekContract.View {

    private SeekContract.Presenter presenter;

    @Override
    protected int setContentView() {
        return R.layout.fragment_seek;
    }

    @Override
    protected void onCreateView(View view) {
        presenter = new SeekPresenter(this);
        //ViewPager viewPager = view.findViewById(R.id.viewPager_seek);
        //viewPager.setAdapter(new SeekPagerAdapter(getChildFragmentManager()));
        //TabLayout tabLayout = view.findViewById(R.id.tabLayout_seek);
        //tabLayout.setupWithViewPager(viewPager);
        SearchView searchView = view.findViewById(R.id.search);
        searchView.setIconifiedByDefault(false);
        searchView.setSubmitButtonEnabled(true);
        searchView.setQueryHint("查找用户");
        searchView.setOnQueryTextListener(this);
    }

    @Override
    public boolean onQueryTextSubmit(String query) {
        EventBus.getDefault().post(new Refresh(Refresh.SEEK));
        presenter.find(query);
        return false;
    }

    @Override
    public boolean onQueryTextChange(String newText) {
        return false;
    }
}